package com.demo.cloud.server.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.refresh.ContextRefresher;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;


@Configuration
public class AutoRefreshConfiguration {

    @Autowired
    private ContextRefresher contextRefresher;

    /**
     * 定时去执行某个方法，refresh方法可以让客户端去拉取配置文件
     */
    @Scheduled(fixedRate =5000L)
    public void autoRefresh(){
        System.out.println("执行定时刷新。。。。。。");
        contextRefresher.refresh();
    }
}
